package com.nd.mobile.study.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;

import com.fuckhtc.gson.Gson;
import com.fuckhtc.gson.annotations.SerializedName;
import com.fuckhtc.gson.reflect.TypeToken;
import com.nd.mobile.study.common.config.Commands;
import com.nd.mobile.study.common.config.ReqParam;
import com.nd.mobile.study.common.util.HttpRequestUtil;

public class HomeworkQCatalog implements Serializable {
	
	private static final long	serialVersionUID	= 1L;

	@SerializedName("SOID")
	private String id;
	
	@SerializedName("OperationTitle")
	private String name;

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}
	
	private Bundle prepareReq(User user) {
		Bundle data = new Bundle();
		data.putString(ReqParam.SOID, this.id);
		data.putString(ReqParam.COMMON_USER_ID, user.getUserId());
		return data;
	}
	
	public HomeworkInfo[] getHomeworks(User user) throws Exception{
		String jsonData = HttpRequestUtil.get(Commands.GET_SUBJECT_HOMEWORK_Q_DETAIL, prepareReq(user));
		Result<HomeworkInfo[]> result = new Gson().fromJson(jsonData, new TypeToken<Result<HomeworkInfo[]>>() {
		}.getType());
		HomeworkInfo[] body = result.getBody();		
		return body;
	}
}
